//
//  BTEDeleteView.swift
//  BTE
//
//  Created by 张文 on 2025/8/16.
//

import UIKit

class BTEDeleteView: UIView {
    
    
     let list = UIScrollView()
    
    fileprivate let baseve = UIView()
    
    private let im = UIImageView(image: UIImage.init(named: "花瓣素材"))
    
    let t1 = UILabel()
    
    let t2 = UILabel()
    
     let im3 = UIImageView(image: UIImage.init(named: BTELanguageManager.shared.localizedImageString(forKey: "Groupfew1312316878")))
    
     let box = UIView()
    
    let loginButton = UIImageView.init(image: UIImage.init(named: "Rectangle132323 94"))
    
    private let loginBut = UILabel.init()
    
    let privicyView = UIView()
    let pribut = UIButton.init()
    let prilabe = UILabel()
    
    override init(frame: CGRect) {
        super.init(frame: frame)
        
        pribut.isSelected = false
        
        addSubview(list)
        list.showsVerticalScrollIndicator = false
        list.snp.makeConstraints { make in
            make.top.left.right.bottom.equalToSuperview()
            make.top.equalToSuperview().offset(32)
        }
        
        list.addSubview(baseve)
        baseve.snp.makeConstraints { make in
            make.edges.equalToSuperview()
            make.width.equalToSuperview()
        }
        
        baseve.addSubview(im)
        baseve.addSubview(t1)
        baseve.addSubview(t2)
        baseve.addSubview(im3)
        baseve.addSubview(box)
        
        im.snp.makeConstraints { make in
            make.centerX.equalToSuperview()
            make.top.equalToSuperview().offset(12)
        }
        

        t1.textAlignment = .center
        t1.font = .systemFont(ofSize: 18, weight: .bold)
        t1.textColor = .black
        t1.snp.makeConstraints { make in
            make.left.right.equalToSuperview().inset(16)
            make.top.equalTo(im.snp.bottom).offset(10)
        }

        t2.textAlignment = .center
        t2.numberOfLines = 0
        t2.font = .systemFont(ofSize: 18, weight: .semibold)
        t2.textColor = .black
        t2.snp.makeConstraints { make in
            make.left.right.equalToSuperview().inset(16)
            make.top.equalTo(t1.snp.bottom).offset(10)
        }
        
        im3.snp.makeConstraints { make in
            make.left.right.equalToSuperview().inset(16)
            make.top.equalTo(t2.snp.bottom).offset(20)
            make.height.equalTo((UIScreen.main.bounds.width-32)*im3.frame.height/im3.frame.width)
        }
        
        box.snp.makeConstraints { make in
            make.top.equalTo(im3.snp.bottom).offset(20)
            make.left.right.equalToSuperview().inset(38)
            make.bottom.equalToSuperview().offset(-44)
            make.height.equalTo(100)
        }
       
        box.addSubview(loginButton)
        box.addSubview(privicyView)
        
        loginButton.snp.makeConstraints { make in
            make.left.right.equalToSuperview()
            make.height.equalTo(50)
            make.bottom.equalToSuperview()
            make.top.equalTo(privicyView.snp.bottom).offset(10)
        }
        
        privicyView.snp.makeConstraints { make in
            make.top.equalToSuperview()
            make.centerX.equalToSuperview()
            make.top.equalTo(loginButton.snp.bottom).offset(28)
        }
        
        privicyView.addSubview(pribut)
        privicyView.addSubview(prilabe)
        
        prilabe.font = .systemFont(ofSize: 14)
        prilabe.textColor = .black
   
    
        pribut.setImage(image: UIImage.init(named: "Ellipse 40")) // Group 1171276716
        pribut.addTarget(self, action: #selector(click), for: .touchUpInside)
        pribut.snp.makeConstraints { make in
            make.width.height.equalTo(18)
            make.top.bottom.left.equalToSuperview()
        }
        
        prilabe.snp.makeConstraints { make in
            make.centerY.equalToSuperview()
            make.right.equalToSuperview()
            make.left.equalTo(pribut.snp.right).offset(12)
        }
        
        loginBut.text = BTELanguageManager.shared.localizedString(forKey: "Account cancellation")
        loginBut.textColor = .colorWithHex("#ffffff")
        loginBut.font = .systemFont(ofSize: 16,weight: .bold)
        loginButton.addSubview(loginBut)
        loginBut.snp.makeConstraints { make in
            make.center.equalToSuperview()
        }
        
        
    }
    
    required init?(coder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
  
    @objc func click(){
        pribut.isSelected = !pribut.isSelected
        pribut.setImage(named: pribut.isSelected ? "Group 1171276716" : "Ellipse 40")
       
    }
}
